package service

import (
	"github.com/go-admin-team/go-admin-core/sdk/service"
	"tuowei.com/app/admin/models"
	"tuowei.com/app/admin/service/dto"
	cDto "tuowei.com/common/dto"
)

type SysRegion struct {
	service.Service
}

// GetPage 获取SysRegion列表
func (e *SysRegion) GetList(c *dto.SysRegionReq, list *[]models.SysRegionList) error {
	var err error
	tx := e.Orm.Debug().
		Scopes(
			cDto.MakeCondition(c.GetNeedSearch()),
		).Table(new(models.SysRegion).TableName()).Select("id,name")
	err = tx.Find(list).Limit(-1).Offset(-1).Error
	if err != nil {
		e.Log.Errorf("db error: %s", err)
		return err
	}
	return nil
}
